library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
About Dataset This dataset is a copy of another Kaggle dataset which can be accessed here: https://www.kaggle.com/c/glioma-radiomics The difference is that I have provided ground truth for the test set (test_GT.csv).
The suffix “omics” in Medical Science is associated with analysis of big sets of features (e.g. Genomics, Proteomics). Radiomics are imaging features (e.g., first order and second order) extracted from Regions of Interest (ROI) in radiology images based on predefined functions and filters. Low grade gliomas (LGG) are a type of brain tumors. Astrocytes and Oligodendrocytes which are two types of brain cells, are considered as origins of LGG. Adult LGG are characterized by different mutations which is important to be correctly identified. With this dataset the goal is to determine if an ROI has 1p19q codeletion (Mutacion=1) or not(Mutacion=0). This plays a key role in predicting patient’s response to chemotherapy and their survival. The dataset provides 640 different radiomics features for each ROI. There are 105 ROIs in the training set and 45 ROIs in the test cohort.
https://www.kaggle.com/datasets/knamdar/radiomics-for-lgg-dataset?select=test_GT.csv
LGG_Data <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/train.csv")
LGG_DataTest <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/test.csv")
LGG_TestGT <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/test_GT.csv")
LGG_DataTest$Mutacion <- LGG_TestGT$Mutacion
LGG_Data <- rbind(LGG_Data,LGG_DataTest)
rownames(LGG_Data) <- LGG_Data$patientID
LGG_Data$patientID <- NULL
pander::pander(table(LGG_Data$Mutacion))
| 0 | 1 |
|---|---|
| 54 | 96 |
studyName <- "LGG"
dataframe <- LGG_Data
outcome <- "Mutacion"
TopVariables <- 10
thro <- 0.80
cexheat = 0.15
Some libraries
library(psych)
library(whitening)
library("vioplot")
pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
| rows | col |
|---|---|
| 150 | 640 |
pander::pander(table(dataframe[,outcome]))
| 0 | 1 |
|---|---|
| 54 | 96 |
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
largeSet <- length(varlist) > 1000
Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns
### Some global cleaning
sdiszero <- apply(dataframe,2,sd) > 1.0e-16
dataframe <- dataframe[,sdiszero]
varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
dataframe <- dataframe[,tokeep]
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
dataframe <- FRESAScale(dataframe,method="OrderLogit")$scaledData
if (!largeSet)
{
hm <- heatMaps(data=dataframe,
Outcome=outcome,
Scale=TRUE,
hCluster = "row",
xlab="Feature",
ylab="Sample",
srtCol=45,
srtRow=45,
cexCol=cexheat,
cexRow=cexheat
)
par(op)
}
The heat map of the data
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
#cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
cormat <- cor(dataframe[,varlist],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Original Correlation",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.999999
DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#>
#> Included: 633 , Uni p: 0.02929148 , Uncorrelated Base: 74 , Outcome-Driven Size: 0 , Base Size: 74
#>
#>
1 <R=1.000,w= 1,N= 399>, Top: 78( 9 )[ 1 : 78 Fa= 78 : 0.975 ]( 78 , 271 , 0 ),<|>Tot Used: 349 , Added: 271 , Zero Std: 0 , Max Cor: 0.999
#>
2 <R=0.999,w= 1,N= 399>, Top: 33( 1 )[ 1 : 33 Fa= 111 : 0.975 ]( 33 , 42 , 78 ),<|>Tot Used: 379 , Added: 42 , Zero Std: 0 , Max Cor: 0.999
#>
3 <R=0.999,w= 1,N= 399>, Top: 2( 1 )[ 1 : 2 Fa= 113 : 0.975 ]( 2 , 3 , 111 ),<|>Tot Used: 382 , Added: 3 , Zero Std: 0 , Max Cor: 0.974
#>
4 <R=0.974,w= 2,N= 199>, Top: 68( 5 )[ 1 : 68 Fa= 143 : 0.937 ]( 67 , 107 , 113 ),<|>Tot Used: 459 , Added: 107 , Zero Std: 0 , Max Cor: 0.977
#>
5 <R=0.977,w= 2,N= 199>, Top: 14( 1 )[ 1 : 14 Fa= 149 : 0.939 ]( 14 , 14 , 143 ),<|>Tot Used: 464 , Added: 14 , Zero Std: 0 , Max Cor: 0.937
#>
6 <R=0.937,w= 3,N= 204>, Top: 67( 1 )[ 1 : 67 Fa= 171 : 0.891 ]( 67 , 98 , 149 ),<|>Tot Used: 519 , Added: 98 , Zero Std: 0 , Max Cor: 0.998
#>
7 <R=0.998,w= 3,N= 204>, Top: 9( 1 )[ 1 : 9 Fa= 177 : 0.899 ]( 9 , 10 , 171 ),<|>Tot Used: 523 , Added: 10 , Zero Std: 0 , Max Cor: 0.905
#>
8 <R=0.905,w= 4,N= 236>, Top: 84( 1 )=[ 2 : 84 Fa= 199 : 0.850 ]( 81 , 120 , 177 ),<|>Tot Used: 571 , Added: 120 , Zero Std: 0 , Max Cor: 0.997
#>
9 <R=0.997,w= 4,N= 236>, Top: 14( 1 )[ 1 : 14 Fa= 204 : 0.849 ]( 14 , 14 , 199 ),<|>Tot Used: 572 , Added: 14 , Zero Std: 0 , Max Cor: 0.855
#>
10 <R=0.855,w= 5,N= 38>, Top: 16( 1 )[ 1 : 16 Fa= 211 : 0.800 ]( 16 , 19 , 204 ),<|>Tot Used: 575 , Added: 19 , Zero Std: 0 , Max Cor: 0.816
#>
11 <R=0.816,w= 5,N= 38>, Top: 1( 1 )[ 1 : 1 Fa= 211 : 0.800 ]( 1 , 1 , 211 ),<|>Tot Used: 575 , Added: 1 , Zero Std: 0 , Max Cor: 0.799
#>
12 <R=0.799,w= 6,N= 0>
#>
[ 12 ], 0.7994857 Decor Dimension: 575 . Cor to Base: 269 , ABase: 40 , Outcome Base: 0
#>
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]
pander::pander(sum(apply(dataframe[,varlist],2,var)))
810
pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))
198
pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))
4.91
pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))
3.29
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
UPSTM <- attr(DEdataframe,"UPSTM")
gplots::heatmap.2(1.0*(abs(UPSTM)>0),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
}
if (!largeSet)
{
cormat <- cor(DEdataframe[,varlistc],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Correlation after IDeA",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
par(op)
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.7994857
classes <- unique(dataframe[,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
datasetframe.umap = umap(scale(dataframe[,varlist]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[,outcome],col=raincolors[dataframe[,outcome]+1])
datasetframe.umap = umap(scale(DEdataframe[,varlistc]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After IDeA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[,outcome],col=raincolors[DEdataframe[,outcome]+1])
univarRAW <- uniRankVar(varlist,
paste(outcome,"~1"),
outcome,
dataframe,
rankingTest="AUC")
100 : wavelet.HHH_firstorder_10Percentile 200 :
wavelet.HHL_firstorder_Uniformity 300 : wavelet.HLH_glcm_Imc1 400 :
wavelet.HLL_gldm_GrayLevelVariance 500 :
wavelet.LHH_glrlm_LongRunLowGrayLevelEmphasis
600 : wavelet.LHL_glszm_LargeAreaHighGrayLevelEmphasis
univarDe <- uniRankVar(varlistc,
paste(outcome,"~1"),
outcome,
DEdataframe,
rankingTest="AUC",
)
100 : La_wavelet.HHH_firstorder_10Percentile 200 :
La_wavelet.HHL_firstorder_Uniformity 300 : wavelet.HLH_glcm_Imc1 400 :
La_wavelet.HLL_gldm_GrayLevelVariance 500 :
La_wavelet.LHH_glrlm_LongRunLowGrayLevelEmphasis
600 : La_wavelet.LHL_glszm_LargeAreaHighGrayLevelEmphasis
univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")
##topfive
topvar <- c(1:length(varlist)) <= TopVariables
pander::pander(univarRAW$orderframe[topvar,univariate_columns])
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| original_firstorder_Skewness | 0.34095 | 0.841 | -0.679 | 0.99 | 0.840 | 0.780 |
| original_glcm_ClusterShade | 0.38451 | 1.104 | -0.841 | 1.42 | 0.509 | 0.755 |
| wavelet.HLL_glcm_ClusterShade | -0.47639 | 1.307 | 0.884 | 1.72 | 0.538 | 0.737 |
| wavelet.HLL_firstorder_Skewness | -0.30857 | 0.904 | 0.509 | 1.10 | 0.534 | 0.736 |
| original_firstorder_Median | -0.22280 | 0.858 | 0.598 | 1.10 | 0.981 | 0.732 |
| original_glcm_MaximumProbability | -0.11040 | 0.790 | 0.936 | 1.41 | 0.154 | 0.722 |
| original_gldm_LargeDependenceHighGrayLevelEmphasis | -0.00634 | 0.714 | 0.912 | 1.31 | 0.562 | 0.711 |
| original_glcm_JointEnergy | -0.02333 | 0.797 | 0.863 | 1.34 | 0.405 | 0.710 |
| original_firstorder_Mean | -0.17862 | 0.883 | 0.519 | 1.06 | 0.949 | 0.702 |
| original_glszm_LargeAreaHighGrayLevelEmphasis | 0.21656 | 1.113 | 1.284 | 1.60 | 0.196 | 0.700 |
topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]
theLaVar <- rownames(finalTable)[str_detect(rownames(finalTable),"La_")]
pander::pander(univarDe$orderframe[topLAvar,univariate_columns])
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| original_firstorder_Skewness | 0.340947 | 0.8406 | -0.67881 | 0.9905 | 0.83988 | 0.780 |
| La_original_glcm_Idmn | 0.037343 | 0.2159 | -0.27010 | 0.3876 | 0.73251 | 0.762 |
| original_glcm_ClusterShade | 0.384511 | 1.1037 | -0.84057 | 1.4157 | 0.50941 | 0.755 |
| La_original_gldm_GrayLevelNonUniformity | -0.000621 | 0.0313 | 0.04464 | 0.0671 | 0.00279 | 0.749 |
| La_wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation | -0.045862 | 0.1153 | 0.06854 | 0.1609 | 0.13121 | 0.748 |
| La_wavelet.HLL_glszm_GrayLevelNonUniformity | 0.047004 | 0.2238 | -0.16664 | 0.2291 | 0.71815 | 0.748 |
| La_wavelet.LHL_glszm_GrayLevelNonUniformity | 0.007005 | 0.2067 | -0.16798 | 0.1987 | 0.92257 | 0.743 |
| La_wavelet.HLL_glszm_HighGrayLevelZoneEmphasis | -0.006867 | 0.0145 | 0.00947 | 0.0253 | 0.18132 | 0.738 |
| wavelet.HLL_glcm_ClusterShade | -0.476394 | 1.3069 | 0.88439 | 1.7240 | 0.53805 | 0.737 |
| wavelet.HLL_firstorder_Skewness | -0.308573 | 0.9039 | 0.50922 | 1.0965 | 0.53357 | 0.736 |
dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")
theSigDc <- dc[theLaVar]
names(theSigDc) <- NULL
theSigDc <- unique(names(unlist(theSigDc)))
theFormulas <- dc[rownames(finalTable)]
deFromula <- character(length(theFormulas))
names(deFromula) <- rownames(finalTable)
pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
| mean | total | fraction |
|---|---|---|
| 2.42 | 516 | 0.815 |
allSigvars <- names(dc)
dx <- names(deFromula)[1]
for (dx in names(deFromula))
{
coef <- theFormulas[[dx]]
cname <- names(theFormulas[[dx]])
names(cname) <- cname
for (cf in names(coef))
{
if (cf != dx)
{
if (coef[cf]>0)
{
deFromula[dx] <- paste(deFromula[dx],
sprintf("+ %5.3f*%s",coef[cf],cname[cf]))
}
else
{
deFromula[dx] <- paste(deFromula[dx],
sprintf("%5.3f*%s",coef[cf],cname[cf]))
}
}
}
}
finalTable <- rbind(finalTable,univarRAW$orderframe[theSigDc[!(theSigDc %in% rownames(finalTable))],univariate_columns])
orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- deFromula[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]
Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")
finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
| DecorFormula | caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | RAWAUC | fscores | |
|---|---|---|---|---|---|---|---|---|---|
| original_firstorder_Skewness | 0.340947 | 0.8406 | -0.67881 | 0.9905 | 0.83988 | 0.780 | 0.780 | NA | |
| La_original_glcm_Idmn | + 1.000original_glcm_Idmn -0.927original_glcm_Idn | 0.037343 | 0.2159 | -0.27010 | 0.3876 | 0.73251 | 0.762 | 0.542 | -1 |
| original_glcm_ClusterShade | 0.384511 | 1.1037 | -0.84057 | 1.4157 | 0.50941 | 0.755 | 0.755 | NA | |
| La_original_gldm_GrayLevelNonUniformity | + 1.000original_gldm_GrayLevelNonUniformity -0.994original_glrlm_GrayLevelNonUniformity | -0.000621 | 0.0313 | 0.04464 | 0.0671 | 0.00279 | 0.749 | 0.493 | -1 |
| La_wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation | -1.066wavelet.HLL_firstorder_InterquartileRange + 1.000wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation | -0.045862 | 0.1153 | 0.06854 | 0.1609 | 0.13121 | 0.748 | 0.511 | -1 |
| La_wavelet.HLL_glszm_GrayLevelNonUniformity | -0.969original_shape_VoxelVolume + 1.000wavelet.HLL_glszm_GrayLevelNonUniformity | 0.047004 | 0.2238 | -0.16664 | 0.2291 | 0.71815 | 0.748 | 0.613 | -1 |
| La_wavelet.LHL_glszm_GrayLevelNonUniformity | -0.901original_shape_VoxelVolume + 1.000wavelet.LHL_glszm_GrayLevelNonUniformity | 0.007005 | 0.2067 | -0.16798 | 0.1987 | 0.92257 | 0.743 | 0.607 | 0 |
| La_wavelet.HLL_glszm_HighGrayLevelZoneEmphasis | -0.989wavelet.HLL_glrlm_HighGrayLevelRunEmphasis + 1.000wavelet.HLL_glszm_HighGrayLevelZoneEmphasis | -0.006867 | 0.0145 | 0.00947 | 0.0253 | 0.18132 | 0.738 | 0.511 | 0 |
| wavelet.HLL_glcm_ClusterShade | -0.476394 | 1.3069 | 0.88439 | 1.7240 | 0.53805 | 0.737 | 0.737 | NA | |
| wavelet.HLL_firstorder_Skewness | -0.308573 | 0.9039 | 0.50922 | 1.0965 | 0.53357 | 0.736 | 0.736 | NA | |
| wavelet.HLL_glszm_GrayLevelNonUniformity | NA | 0.383172 | 1.1301 | 0.03792 | 1.1214 | 0.08156 | 0.613 | 0.613 | NA |
| wavelet.LHL_glszm_GrayLevelNonUniformity | NA | 0.319464 | 1.0407 | 0.02216 | 1.0581 | 0.05370 | 0.607 | 0.607 | NA |
| original_shape_VoxelVolume | NA | 0.346934 | 1.1224 | 0.21112 | 1.1863 | 0.03431 | 0.555 | 0.555 | 27 |
| wavelet.HLL_firstorder_InterquartileRange | NA | 0.198194 | 0.8825 | 0.05217 | 1.1175 | 0.93350 | 0.543 | 0.543 | NA |
| original_glcm_Idmn | NA | -0.008491 | 0.8174 | -0.20185 | 1.0893 | 0.86299 | 0.542 | 0.542 | NA |
| original_glcm_Idn | NA | -0.049468 | 0.8146 | 0.07367 | 1.1234 | 0.74562 | 0.542 | 0.542 | 1 |
| wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation | NA | 0.165458 | 0.9506 | 0.12417 | 1.2083 | 0.99377 | 0.511 | 0.511 | NA |
| wavelet.HLL_glszm_HighGrayLevelZoneEmphasis | NA | 0.240722 | 0.9642 | 0.32542 | 1.0827 | 0.23259 | 0.511 | 0.511 | NA |
| wavelet.HLL_glrlm_HighGrayLevelRunEmphasis | NA | 0.250344 | 0.9771 | 0.31946 | 1.0915 | 0.22983 | 0.504 | 0.504 | 11 |
| original_gldm_GrayLevelNonUniformity | NA | 0.352015 | 1.1203 | 0.45162 | 1.3030 | 0.00371 | 0.493 | 0.493 | NA |
| original_glrlm_GrayLevelNonUniformity | NA | 0.354630 | 1.1374 | 0.40928 | 1.2923 | 0.00129 | 0.486 | 0.486 | NA |